define(function(){
	var toor=
	{
		mounted:function(){
			document.querySelector('body').scrollTop=0;
			document.querySelector('#app').scrollTop=0;
		},
		data:function () 
		{
			 return{navRight:{},userList:[], todo_num:0,cc_num:0}
		},
		
		methods:
		{
			back:function(n)
    		{
    			window.Router.go(n);
    		},
			urlAddTooken:function(url)
			{
				var token=sessionStorage.getItem('access_token');
		  	    if(url.indexOf('?')!=-1)
		  	    {
		  	    	  url=url+'&access_token='+token
		  	    }else
		  	    {
		  	    	 url=url+'?access_token='+token;
		  	    };
		  	    return url
			},
			myAjax:function(target)
			{
				 var options=
				 {
				 	tooken:true
				 };
				 if(!target.url||!target.type)return;
				 $.extend(options, target);
				 $.ajax({
				 	type:options.type,
     	 		 	url: (options.tooken?(this.urlAddTooken(options.url)):(options.url)),
     	 		 	async:true,
     	 		 	data:options.data,
     	 		 	dataType:'json',
     	 		 	success:function(data)
     	 		 	{
     	 		 		 options.callback && options.callback(data);
     	 		 		  /*switch(data.code)
     	 		 		  {
     	 		 		  	 case 200 :
     	 		 		  	 case '200' :
     	 		 		  	  options.callback && options.callback(data);
     	 		 	
     	 		 		  	 break;
     	 		 		  };*/
     	 		 	},
     	 		 	error:function(data)
     	 		 	{
     	 		 		 switch(data.status)
     	 		 		  {
     	 		 		  	 case 401 :
     	 		 		  	 case '401' :
     	 		 		  	  location.href='login.html'
     	 		 		  	 break;
     	 		 		  	 default:
     	 		 		  	 try{
     	 		 		  	 	 layer.msg('数据异常');
	     	 		 		  	 layer.closeAll({time:500})
     	 		 		  	 }catch(e){
     	 		 		  	 	$.alert('数据异常')
     	 		 		  	 }
     	 		 		  	 options.error && options.error(data);
     	 		 		  	 break;
     	 		 		  };
     	 		 	}
				 });
			},
			remfn:function()
			{
				setRem();
				window.addEventListener("orientationchange", setRem);
				window.addEventListener("resize", setRem);
				function setRem() {
				  var html = document.querySelector("html");
				  var width = html.getBoundingClientRect().width;
				  if(width>=414)
				  {
				  	width=414;
				  };
				  html.style.fontSize = width / 16 + "px";
				}
			},
			zerofill:function(num)
			{
				if(num<10)
				{
					return '0'+num
				}else
				{
					 return num
				}
			},
			approveNum:function()
			{
				var _this=this;
				this.myAjax({
     	 		 	 type:"get",
     	 		 	 tooken:false,
     	 		 	 url: '/bpms/approves/num',
     	 		 	 callback:function(data)
     	 		 	 { 
     	 		 	 	if(data.code=='200')
     	 		 	 	{
     	 		 	 		_this.todo_num=data.data.todo_num;
     	 		 	 		_this.cc_num=data.data.cc_num;
     	 		 	 	}
     	 		 	 }
     	 		 });
			},
			lookImg:function(ev,files,pStart)
     	 	{
                  if(files.length<=0)return;
                  var arr=[],start=$(ev.target).attr('data-index');
                  if(pStart)start=pStart;
     	 		  for(var i=0,img;img=files[i++];)
     	 		  {
     	 		  	    arr.push({
     	 		  	      "alt":'',
					      "pid": '', //图片id
					      "src": img.file_url, //原图地址
					      "thumb": img.file_url
     	 		  	    })
     	 		  }
     	 		 var json=
     	 		 {
					  "title": "", //相册标题
					  "id":'', //相册id
					  "start":start, //初始显示的图片序号，默认0
					  "data":arr   //相册包含的图片，数组格式
     	 		 };
     	 		layer.photos({
				    photos: json,
				    anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
				  });
     	 	}
		}
	};
	return {"toor":toor }
});